package com.aiyige.page.publish.info;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.aiyige.R;
import com.aiyige.utils.widget.BaseBottomDialogFragment;

import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by zhuyakun on 2017/11/13.
 */

public class PublishInfoActionBottomDialog extends BaseBottomDialogFragment {
    Unbinder unbinder;
    Listener listener;

    public Listener getListener() {
        return listener;
    }

    public void setListener(Listener listener) {
        this.listener = listener;
    }

    public static PublishInfoActionBottomDialog newInstance() {
        return new PublishInfoActionBottomDialog();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.publish_info_action_bottom_dialog, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.previewBtn, R.id.finishBtn, R.id.cancelBtn})
    public void onViewClicked(View view) {
        if (listener != null) {
            switch (view.getId()) {
                case R.id.previewBtn:
                    listener.preview();
                    break;
                case R.id.finishBtn:
                    listener.finish();
                    break;
                case R.id.cancelBtn:
                    listener.cancel();
                    break;
            }
        }
        dismiss();
    }

    public interface Listener {
        void preview();

        void finish();

        void cancel();
    }
}
